/***********************************************************************
 * $Id:: handlers.c 3871 2010-07-16 11:50:22Z gerritdewaard            $
 *
 * Project: LPC1100 BLDC Motor Control AN  
 *
 * Description:
 *			
 *     
 *
 ***********************************************************************
 * Software that is described herein is for illustrative purposes only
 * which provides customers with programming information regarding the
 * products. This software is supplied "AS IS" without any warranties.
 * NXP Semiconductors assumes no responsibility or liability for the
 * use of the software, conveys no license or title under any patent,
 * copyright, or mask work right to the product. NXP Semiconductors
 * reserves the right to make changes in the software without
 * notification. NXP Semiconductors also make no representation or
 * warranty that such application will be suitable for the specified
 * use without further testing or modification.
 **********************************************************************/

#include "application.h"


volatile uint32_t SysTick_cntr = 0;
extern volatile MOTOR_TypeDef Motor;
extern volatile uint32_t bldc_Tick;


/*****************************************************************************
** Function name:		PIOINT0_IRQHandler
**
** Descriptions:		Use one GPIO pin(port0 pin1) as interrupt source
**
** parameters:			None
** Returned value:		None
** 
*****************************************************************************/
#ifndef GPIO_GENERIC_INTS

void PIOINT2_IRQHandler(void)
{
  	uint32_t regVal;

  	regVal = LPC_GPIO2->MIS;

  	switch (regVal)
  	{
  	case (1<<HALL_A_PIN):
			/* Calculate the actual RPM */
			vBLDC_CalcRPM(&Motor);
			break;
//  	case (1<<JOY_C_PIN):
	default:
  		break;
  	}
  	/* Clear all interrupt sources */
	LPC_GPIO2->IC = 0xFFF;
  return;
}
#endif //GPIO_GENERIC_INTS


void SysTick_Handler (void)
{
	SysTick_cntr++;
	bldc_Tick++;
}


